#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
using namespace std;


    string addBinary(string a, string b) {
        string str;
        reverse(a.begin(), a.end());
        reverse(b.begin(), b.end());
        int cur1 = 0, cur2 = 0, ret = 0;
        while (cur1 < a.size() && cur2 < b.size()) {
            ret += (a[cur1] - '0') + (b[cur2] - '0');

            str += ret % 2 + '0';
            ret /= 2;
            cur1++;
            cur2++;
        }

        while (cur1 < a.size()) {
            ret += (a[cur1] - '0');
            str += ret % 2 + '0';
            ret /= 2;
            cur1++;
        }
        while (cur2 < b.size()) {
            ret += (b[cur2] - '0');
            str += ret % 2 + '0';
            ret /= 2;
            cur2++;
        }
        if (ret == 1)
            str += ret % 2 + '0';
        reverse(str.begin(), str.end());
        return str;
    }
int main()
{
    string a = "1";
    string b = "111";

    string str = addBinary(a, b);
    cout << str << endl;
    return 0;
}